using UnityEngine;

public class TableTennisDialog : MonoBehaviour
{
	public delegate void OnDialogComplete(bool complete);

	protected OnDialogComplete onDialogComplete;

	public UILabel yesLabel;

	public UILabel noLabel;

	public UILabel okLabel;

	public UILabel textLabel;

	public UILabel headerLabel;

	public GameObject YesNoObject;

	public GameObject okObject;

	public GameObject forceCancel;

	public GameObject dialogGameObject;

	public static TableTennisDialog instance { get; protected set; }

	private void Awake()
	{
		instance = this;
	}

	private void OnDestroy()
	{
		instance = null;
	}

	public void ShowYesNo(string header, string text, string yes, string no, OnDialogComplete onCompleteDialog, bool showForceCancel = false)
	{
		UITools.ChangeText(headerLabel, header);
		Debug.Log("Show yes no::: " + text);
		YesNoObject.SetActive(true);
		okObject.SetActive(false);
		onDialogComplete = onCompleteDialog;
		textLabel.text = text;
		yesLabel.text = yes;
		noLabel.text = no;
		forceCancel.SetActive(showForceCancel);
		NavigationManager.instance.PushModal(dialogGameObject);
	}

	public void ShowNotEnoughCoins(int coinsNeeded, CurrencyType currency = CurrencyType.coins)
	{
		TableTennisMainNavigation tableTennisMainNavigation = NavigationManager.instance as TableTennisMainNavigation;
		if (tableTennisMainNavigation != null)
		{
			tableTennisMainNavigation.PushCurrencyStore(currency);
		}
	}

	private void OnShowNotEnoughCoinsComplete(bool success)
	{
		NavigationManager.instance.Pop();
		Debug.Log("Success + " + success);
		if (success)
		{
			Debug.Log("Success");
			TableTennisMainNavigation tableTennisMainNavigation = NavigationManager.instance as TableTennisMainNavigation;
			if (tableTennisMainNavigation != null)
			{
				Debug.Log("Main Navigation");
				tableTennisMainNavigation.PushCurrencyStore();
			}
		}
	}

	public void ShowOk(string header, string text, string ok, OnDialogComplete onCompleteDialog, bool showForceCancel = false)
	{
		UITools.ChangeText(headerLabel, header);
		YesNoObject.SetActive(false);
		okObject.SetActive(true);
		onDialogComplete = onCompleteDialog;
		textLabel.text = text;
		okLabel.text = ok;
		forceCancel.SetActive(showForceCancel);
		NavigationManager.instance.PushModal(dialogGameObject);
	}

	public void OnOk()
	{
		OnDialogComplete onDialogComplete = this.onDialogComplete;
		this.onDialogComplete = null;
		if (onDialogComplete != null)
		{
			onDialogComplete(true);
		}
		else
		{
			NavigationManager.instance.Pop(true);
		}
	}

	public void OnCancel()
	{
		OnDialogComplete onDialogComplete = this.onDialogComplete;
		this.onDialogComplete = null;
		if (onDialogComplete != null)
		{
			onDialogComplete(false);
		}
		else
		{
			NavigationManager.instance.Pop(true);
		}
	}
}
